package com.netty.coder;

import utl.mofen.utils.ZipUtil;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToByteEncoder;


public class DelphiZipEncoder extends ByteToByteEncoder {
	
    public void encode(ChannelHandlerContext ctx,
            ByteBuf in, ByteBuf out) throws Exception {
    	int l = in.readableBytes();
    	
    	byte[] buf = new byte[l];
    	
    	in.readBytes(buf);
    	
    	byte[] compressByte = ZipUtil.compress(buf);
    	
    	out.writeBytes(compressByte);
    	
    }
}
